package com.test;

import java.util.Date;
import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.oxy.model.Pager;
import com.oxy.model.dao.MemberDao;
import com.oxy.model.dao.TestDao;
import com.oxy.model.po.MemberPO;
import com.oxy.model.po.TestPO;
import com.oxy.svc.MemberSvc;
import com.oxy.svc.StaticSvc;
import com.oxy.util.SpringUtil;
import com.test.misc.SpringTestClass;


public class SpringTester implements TesterIf {
	public void run(){
		//testDAO();
		testSvc();
		//testMemberSvc();
		//testSpring();
	}
	
	public void testDAO(){
		TestDao dao = (TestDao)SpringUtil.getBean("testDAO");
		Pager pg = new Pager();
		pg.setCurrentPage(1);
		pg.setCurrentPageEndInd(2);
		pg.setCurrentPageStartInd(1);
		pg.setPageSize(10);
		pg.setTotalPage(1);
		List<TestPO> list = dao.list(pg);
		for(TestPO item:list){
			System.out.println(item);
		}
	}
	
	public void testSvc(){
		StaticSvc svc = (StaticSvc)SpringUtil.getBean("staticSvc");
		//String ret = svc.getJsContent("test.js");
		String ret = svc.getCssContent("bootstrap.css");
		//System.out.println("result = "+ret);
	}
	
	public void testMemberSvc() {
		MemberSvc svc = (MemberSvc)SpringUtil.getBean("memberSvc");
		long count = svc.getMemberCount();
		System.out.println("count = "+count);
		
		MemberPO po = new MemberPO();
		po.setEmail("test006@oxy.com");
		po.setNickname("test006");
		po.setPassword("password006");
		po.setStatus(true);
		po.setGid(1);
		po.setRegdate(new Date());
		long regrst = svc.regMember(po);
		System.out.println("register result = "+regrst+", uid=" + po.getUid());
		
		count = svc.getMemberCount();
		System.out.println("count = "+count);
	}
	
	public void testSpring() {
		SpringTestClass sc = (SpringTestClass)SpringUtil.getBean("springTestBean");
		System.out.println("####################### Got value="+sc.dumpValue());
	}
}
